var api = require('../../utils/api.js')
var app = getApp()

import Drawer  from '../../utils/redraw';
let drawer = new Drawer("draw-c");

Page({
  data: {
    systemInfo: {},
    _api: {},
    dashImage:"",
    figure: "",
    colorImageList: [],
    animation: []
  },

  onLoad: function (options) {
    var that = this
    app.getSystemInfo(function(res) {
      that.setData({
        systemInfo: res
      })
    })

    that.setData({
      _api: api
    })
    if (options === null || options.rowId === null) {
      // this.setData({hidden: true, toastHidden: false});
      return
    } else {
      api.get(`${api.HOST_EASYDRAW_PRD}${api.FIRGURE_IMAGE}/${options.rowId}`)
        .then(res => {
            console.log(res);
          that.setData({
            figure: res.data.data.figure,
            dashImage: res.data.data.dashImg,
            colorImageList: res.data.data.colorImageList,
            animation: res.data.data.animation
          })
          
          console.log("the image url:"+this.data.figure);
          drawer.drawImage(this.data.figure);
        })
        
    }
  },

  onPullDownRefresh () {
    wx.stopPullDownRefresh()
  },

  /**
   * 加载简笔画图片
   */
  drawImage (){
    console.log("the image url:"+this.data.figure);
    drawer.drawImage(this.data.figure);
  }
})
